package com.bestcem.xm.qdes.controller.v3;

import com.bestcem.xm.common.core.domain.web.XmResultJson;
import com.bestcem.xm.component.security.context.SecurityContextHolder;
import com.bestcem.xm.qdes.controller.param.ProjectCreateParam;
import com.bestcem.xm.qdes.controller.vo.QdesProjectVo;
import com.bestcem.xm.qdes.service.QdesQstructService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Slf4j
@Api(tags = "问卷结构-V3")
@RestController
@RequiredArgsConstructor
@RequestMapping("/qdes/v3/qstruct")
public class ProjectQstructV3Controller {

    private @NonNull QdesQstructService qdesQstructService;

    @ApiOperation(value = "导入项目后命名")
    @PostMapping("/{id:[a-fA-F0-9]{24}}")
    public XmResultJson<QdesProjectVo> projectStructImport(@PathVariable("id") String id, @RequestBody @Validated ProjectCreateParam param) {
        param.setUserId(SecurityContextHolder.getUserId());
        param.setOrgId(SecurityContextHolder.getOrgId());
        return XmResultJson.success(qdesQstructService.projectQStructImport(id, param));
    }
}